package com.come4loves.game.module.skill.skillcardimpl;

import org.springframework.stereotype.Component;

import com.come4loves.game.module.fight.action.AttributeChangeAction;
import com.come4loves.game.module.fight.action.BatchAction;
import com.come4loves.game.module.fight.constants.FighterAttribute;
import com.come4loves.game.module.fight.helper.FightHelper;
import com.come4loves.game.module.fight.model.FightCard;
import com.come4loves.game.module.fight.model.FightContext;
import com.come4loves.game.module.skill.AbstractSkillCardParser;
import com.come4loves.game.module.skill.model.DamageModel;
import com.come4loves.game.module.skill.model.SkillModel;
@Component
public class HealSkill extends AbstractSkillCardParser {

	@Override
	public String skillId() {
		return "heal";
	}

	@Override
	public void handerSkill(FightCard attackerCard, FightCard targetCard, SkillModel skillModel,BatchAction batchAction, FightContext fightContext) {
		if (targetCard.isDead()) {
			return;
		}
		int effectValue = Integer.valueOf(skillModel.getEffect().get(skillId()));
		int real = targetCard.getMaxHp() - targetCard.getHp();
		effectValue = effectValue > real ? real : effectValue;
		DamageModel damageModel = FightHelper.realDamage(targetCard, effectValue, false, fightContext.actionRecorder);
		if (damageModel.getRealDamage() >= 0){
			cardDamage(attackerCard, targetCard, damageModel.getRealDamage(),fightContext);
			AttributeChangeAction attributeChangeAction = new AttributeChangeAction(targetCard);
			attributeChangeAction.addAttributeChange(FighterAttribute.HP, damageModel.getRealDamage(), true);
			batchAction.addAction(attributeChangeAction);
		}
	}


}
